<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
    <link href="framework/reset.css" rel="stylesheet">
    <link href="css/register.css" rel="stylesheet">
    <title>饿了么 用户注册</title>
</head>

<body>
    <div class="wrapper" id="register">

        <!-- header部分 -->
        <header>
            <p>用户注册</p>
        </header>

        <!-- 表单部分 -->
        <ul class="form-box">
            <li>
                <div class="title">
                    手机号码：
                </div>
                <div class="content">
                    <input type="text" placeholder="手机号码" v-model="phoneNumber">
                </div>
            </li>
            <li>
                <div class="title">
                    密码：
                </div>
                <div class="content">
                    <input type="password" placeholder="密码" v-model="password">
                </div>
            </li>
            <li>
                <div class="title">
                    确认密码：
                </div>
                <div class="content">
                    <input type="password" placeholder="确认密码" v-model="passwordConfirm">
                </div>
            </li>
            <li>
                <div class="title">
                    用户姓名：
                </div>
                <div class="content">
                    <input type="text" placeholder="用户姓名" v-model="nickname">
                </div>
            </li>
            <li>
                <div class="title">
                    性别：
                </div>
                <div class="content" style="font-size: 3vw;">
                    <input type="radio" name="sex" value="0" style="width:6vw;height: 3.2vw;" v-model="sex">男
                    <input type="radio" name="sex" value="1" style="width:6vw;height: 3.2vw;" v-model="sex">女
                </div>
            </li>
        </ul>
        
        <div class="button-login">
            <p id="tips">{{tips}}</p>
            <button @click="register()">注册</button>
        </div>

        <!-- 底部菜单部分 -->
        <ul class="footer">
            <li onclick="location.href='index.html'">
                <i class="fa fa-home"></i>
                <p>首页</p>
            </li>
            <li>
                <i class="fa fa-compass"></i>
                <p>发现</p>
            </li>
            <li onclick="location.href='orderList.html'">
                <i class="fa fa-file-text-o"></i>
                <p>订单</p>
            </li>
            <li>
                <i class="fa fa-user-o"></i>
                <p>我的</p>
            </li>
        </ul>
    </div>
    <script src="https://fastly.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="js/pageJump.js"></script>
    <script>
        var path=getRequestPath()
        var login=new Vue({
            el:"#register",
            data:{
                tips:'',
                phoneNumber:null,
                password:null,
                passwordConfirm:null,
                nickname:null,
                sex:0
            },
            methods:{
                register:function(){
                    if(this.password!=this.passwordConfirm){
                        this.tips='两次密码输入不一致';
                        return
                    }
                    axios.post(path+"/UserController/saveUser",null,{
                        params:{
                            phoneNumber:this.phoneNumber,
                            password:this.password,
                            nickname:this.nickname,
                            sex:this.sex
                        }
                    }).then((respon)=>{
                        if(respon.data.success==true){
                            window.location.href='login.html';
                        }
                    }).catch((error)=>{
                        console.log(error)
                    })
                }
            }
        })
    </script>
</body>

</html>